#include <stdarg.h>
#include <stdio.h>
#include "concurrent.h"

#define PRINT_FONT_WHI  printf("\e[1;37m"); //白色
#define PRINT_FONT_RED  printf( "\e[1;31m"); //红色
#define PRINT_FONT_BLU  printf("\e[1;34m"); //蓝色

pthread_mutex_t print_mutex=PTHREAD_MUTEX_INITIALIZER;

extern void concurrent_printf(const char* fmt,...){
    va_list args;
    va_start(args,fmt);
    pthread_mutex_lock(&print_mutex);
    vprintf(fmt,args);
    pthread_mutex_unlock(&print_mutex);
    va_end(args);
}

void concurrent_printf_warning(const char* fmt,...){
    va_list args;
    va_start(args,fmt);
    pthread_mutex_lock(&print_mutex);
    PRINT_FONT_RED;
    vprintf(fmt,args);
    PRINT_FONT_WHI;
    pthread_mutex_unlock(&print_mutex);
    va_end(args);
}

void concurrent_printf_reminder(const char* fmt,...){
    va_list args;
    va_start(args,fmt);
    pthread_mutex_lock(&print_mutex);
    PRINT_FONT_BLU;
    vprintf(fmt,args);
    PRINT_FONT_WHI;
    pthread_mutex_unlock(&print_mutex);
    va_end(args);
}